export default {
	data() {
		const {
			age,
			avatar,
			address,
			city,
			city_code,
			class_one_id,
			class_one_name,
			class_three_id,
			class_three_name,
			class_two_id,
			class_two_name,
			content,
			edu_id,
			edu_name,
			exp_id,
			exp_name,
			lat,
			lng,
			nickname,
			label,
			personal_resume,
			sex,
			certificate_image, //资质
			certificate_honor, //荣誉
			life_image //生活
		} = this.$store.state.vuex_userInfo;
		return {
			infoForm: {
				age: age,
				avatar,
				address,
				city,
				city_code,
				class_one_id,
				class_one_name,
				class_three_id,
				class_three_name,
				class_two_id,
				class_two_name,
				content,
				label,
				// edu_id,
				// edu_name,
				// exp_id,
				// exp_name,
				lat,
				lng,
				name: nickname,
				// personal_resume,
				sex,
				certificate_image, //资质
				certificate_honor, //荣誉
				life_image //生活
			},
			sexPicker: false,
			agePicker: false,
			eduPicker: false,
			classPicker: false,
			expPicker: false,
			cityPicker: false,
			directionPopup: false,
			workExpPopup: false,
			startTimePicker: false,
			endTimePicker: false,
			classTagPicker: false,
			isCheck: false,
			defaultClass: [0],
			rules: {
				name: [{
					required: true,
					message: '请输入姓名',
					trigger: 'change',
				}],
				age: [{
					required: true,
					message: '请输入年龄',
					transform(value) {
						return String(value);
					},
					trigger: 'change',
				}],
				// edu_name: [{
				// 	required: true,
				// 	message: '请选择学历',
				// 	trigger: 'change',
				// }],
				class_one_name: [{
					required: true,
					message: '请选择所属行业',
					trigger: 'change',
				}],
				class_three_name: [{
					required: true,
					message: '请选择把关标签',
					trigger: 'change',
				}],
				// exp_name: [{
				// 	required: true,
				// 	message: '请选择从业年限',
				// 	trigger: 'change',
				// }],
				city: [{
					required: true,
					message: '请选择所在城市',
					trigger: 'change',
				}],
				address: [{
					required: true,
					message: '请选择常驻地址',
					trigger: 'change',
				}],
				label: [{
					required: true,
					message: '请填写头衔',
					trigger: 'change',
				}],
				content: [{
					required: true,
					message: '请填写经验或经历介绍',
					trigger: 'change',
				}],
				// personal_resume: [{
				// 	required: true,
				// 	message: '请填写从业经历',
				// 	transform(value) {
				// 		return String(value);
				// 	},
				// 	trigger: 'change',
				// }],
				certificate_image: [{
					validator: (rule, value, callback) => {
						return value.length > 0;
					},
					message: '请上传资质证明',
				}],
				certificate_honor: [{
					validator: (rule, value, callback) => {
						return value.length > 0;
					},
					message: '请上传荣誉证明',
				}],

			}
		}
	},
	onReady() {
		this.$refs.infoForm.setRules(this.rules);
	},
	watch: {
		'infoForm.content'(value) {
			if (value) {
				this.isCheck = true
			}
		}
	},
	methods: {
		confirmAge(e) {
			const nowDay = new Date();
			const age = nowDay.getFullYear() - e.year;
			console.log(age);
			this.infoForm.age = age
		},
		confirmEdu(e) {
			const index = e[0]
			this.infoForm.edu_id = this.eduList[index].id;
			this.infoForm.edu_name = this.eduList[index].name
		},
		confirmClass(e) {
			this.isCheck = true;
			const index = e[0];
			this.defaultClass = e;
			this.infoForm.class_one_id = this.classList[index].id;
			this.infoForm.class_one_name = this.classList[index].name
			this.infoForm.class_two_id = '';
			this.infoForm.class_two_name = '';
			this.infoForm.class_three_id = '';
			this.infoForm.class_three_name = '';
		},
		confirmExp(e) {
			const index = e[0]
			this.infoForm.exp_id = this.expList[index].id;
			this.infoForm.exp_name = this.expList[index].name
		},
		confirmCity(e) {
			console.log(e);
			this.infoForm.city = e.province.label + ',' + e.city.label
			this.infoForm.city_code = e.province.value + ',' + e.city.value
		},
		confirmStartTime(e) {
			this.workForm.timeRange[0] = `${e.year}-${e.month}`
		},
		confirmEndTime(e) {
			this.workForm.timeRange[1] = `${e.year}-${e.month}`
		},
		confirmClassTag(e) {
			this.infoForm.class_two_id = e.oneClass.id;
			this.infoForm.class_two_name = e.oneClass.name;
			this.infoForm.class_three_id = e.tags.map(item => item.id).toString();
			this.infoForm.class_three_name = e.tags.map(item => item.name).toString();
		}
	}
}